<template>
  <div class="sidebar">
    <div style="line-height: 62px; color: #f0f0f0; font-size: 24px; width: 100%; height: 22%">
      电影购票系统
    </div>
    <div class="clear"></div>
    <el-menu
      class="sidebar-el-menu"
      :default-active="activeIndex"
      :collapse="collapse"
      background-color="#334256"
      text-color="#ffffff"
      active-text-color="#ffd04b"
      @select="onRouter"
    >
      <el-menu-item index="AdminMovies" style="font-size: 17px"
        ><VideoCamera
          style="width: 1em; height: 1em; margin-right: 8px"
        />&emsp;电影管理</el-menu-item
      >
      <el-menu-item index="AdminAuditorium" style="font-size: 17px"
        ><VideoCameraFilled
          style="width: 1em; height: 1em; margin-right: 8px"
        />&emsp;影厅管理</el-menu-item
      >
      <el-menu-item index="AdminOrders" style="font-size: 17px"
        ><List style="width: 1em; height: 1em; margin-right: 8px" />&emsp;订单管理</el-menu-item
      >
      <el-menu-item index="AdminComment" style="font-size: 17px"
        ><Comment style="width: 1em; height: 1em; margin-right: 8px" />&emsp;评论管理</el-menu-item
      >
      <el-menu-item index="AdminStatistics" style="font-size: 17px"
        ><Histogram
          style="width: 1em; height: 1em; margin-right: 8px"
        />&emsp;统计分析</el-menu-item
      >
      <el-sub-menu index="2">
        <template #title
          ><Management style="width: 1em; height: 1em; margin-right: 8px" />&emsp;排片管理</template
        >
        <el-menu-item index="AdminArrangement" style="font-size: 17px"
          >&emsp;&emsp;<OfficeBuilding
            style="width: 1em; height: 1em; margin-right: 8px"
          />&emsp;场次列表</el-menu-item
        >
      </el-sub-menu>
      <el-menu-item index="AdminSuggest" style="font-size: 17px" v-if="store.state.admin"
        ><Star style="width: 1em; height: 1em; margin-right: 8px" />&emsp;推荐管理</el-menu-item
      >
      <el-menu-item index="AdminUser" v-if="store.state.admin" style="font-size: 17px"
        ><UserFilled
          style="width: 1em; height: 1em; margin-right: 8px"
        />&emsp;用户管理</el-menu-item
      >
    </el-menu>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'

const router = useRouter()
const store = useStore()

const collapse = ref(false)

const activeIndex = ref('1')
const pageList = reactive({
  PhoneAdminMovies: '电影管理',
  PhoneAdminAuditorium: '影厅管理',
  PhoneAdminOrders: '订单管理',
  PhoneAdminComment: '评论管理',
  PhoneAdminStatistics: '统计分析',
  PhoneAdminArrangement: '场次列表',
  PhoneAdminSuggest: '推荐管理',
  PhoneAdminUser: '用户管理'
})
const onRouter = (key, keyPath) => {
  store.commit('setPageName', pageList[keyPath[keyPath.length - 1]])
  router.push('/' + 'Phone' + keyPath[keyPath.length - 1])
  store.commit('setIsHome', false)
}
</script>

<style lang="scss" scoped>
@import '@/assets/scss/adminAside.scss';
</style>
